import TableContent from './TableContent'
import type { ColumnType } from 'antd/es/table/interface'
import type { IProps } from './type'
export type { TableColumns } from './type'

/**
 * 合并renders中与columns中key相等的元素
 * @param columns
 * @param renders
 * @returns 合并renders后的columns
 */
export function mergeRenders<T>(
	columns: ColumnType<T>[],
	renders: IProps['renders']
): ColumnType<T>[] | undefined {
	if (!columns.length) return undefined

	const copyColumns = [...columns]
	for (const renderKey in renders) {
		copyColumns.forEach((column) => {
			if (column.key === renderKey) {
				column.render = renders[renderKey]
			}
		})
	}

	return copyColumns
}

export default TableContent
